package site.zbox.tool.swing.xml.component;

import javax.swing.JComponent;
import javax.swing.JToolBar;

import org.dom4j.Element;

import site.zbox.tool.lang.StringUtils;
import site.zbox.tool.lang.Version;
import site.zbox.tool.swing.xml.IComponentParser;

@Version("2021.08.12")
public class ToolBarComponentParser implements IComponentParser {
    @Override
    public String name() {
        return "ToolBar";
    }

    @Override
    public JComponent parse(Element element) {
        final JToolBar toolBar = new JToolBar();
        final String floatable = element.attributeValue("floatable");
        if (StringUtils.isNotEmpty(floatable)) {
            toolBar.setFloatable("true".equalsIgnoreCase(floatable));
        }
        return toolBar;
    }
}
